import http from '../utils/http'

const apiKey = 'ba0fed7e8ff300fe031991f332bcf984'
const sign = localStorage.getItem('sign')

export const getSign = (code) => http.get('?s=/api/hdgl/action_authorize', {
  api_key: apiKey,
  code,
  origin: 'hpl'
})

// 任务列表接口
export const getTaskList = () => http.post('?s=api/Hdgl/get_task_list', {
  userid: '2168',
  api_key: apiKey,
  sign
})

// 任务详情接口
export const getTaskInfo = (taskId) => http.post('?s=api/Hdgl/get_task_info', {
  userid: '2168',
  task_id: taskId,
  api_key: apiKey,
  sign
})

// 日志列表接口
export const getDiaryList = () => http.post('?s=api/Hdgl/get_diary_list', {
  userid: '2168',
  api_key: apiKey,
  sign
})

// 日志详情接口
export const getDiaryInfo = (diaryId) => http.post('?s=api/Hdgl/get_diary_info', {
  userid: '2168',
  diary_id: diaryId,
  api_key: apiKey,
  sign
})

// 插入日志接口
export const addDiary = ({
  taskId,
  costTime,
  content,
  costCash,
  partnerUserids,
  images,
  files
}) => http.post('?s=api/Hdgl/add_diary', {
  userid: '2168',
  task_id: taskId,
  cost_time: costTime,
  content,
  cost_cash: costCash,
  partner_userids: partnerUserids,
  images: images || '',
  files: files || '',
  api_key: apiKey,
  sign
})
